package com.qf.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.annotation.RequiresPermissionsDesc;
import com.qf.pojo.DtsFootprint;
import com.qf.service.DtsFootprintService;
import com.qf.util.ResponseUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author lixu
 */
@RestController
@RequestMapping("/admin/footprint")
@CrossOrigin
public class FootprintController {

    @Autowired
    private DtsFootprintService dtsFootprintService;

    /**
     * #### 会员足记
     *
     * ##### 2.1.5.1. 会员足记列表
     *
     * - 接口地址 : http://localhost:8083/admin/footprint/list?page=1&limit=20&sort=add_time&order=desc
     *
     * - 下行数据 :
     */
    @RequiresPermissionsDesc(menu = {"用户管理","会员足记"},button = "查询")
    @RequiresPermissions(value = "admin:footprint:list")
    @GetMapping("/list")
    public Object list(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "20") Integer limit,
                       String sort, String order, Integer userId, Integer goodsId){
        IPage<DtsFootprint> iPage = dtsFootprintService.findListByQuery(page,limit,sort,order,userId,goodsId);
        Map data = new HashMap<>();
        data.put("total", iPage.getTotal());
        data.put("items", iPage.getRecords());
        return ResponseUtil.ok(data);
    }
}
